package sixkey.listener;

/**
 * ClassName:MyEventListener
 * Package:sixkey.listener
 * Description
 *
 * @Author:@wenxueshi
 * @Create:2023/7/13 - 2:17
 * @Version:v1.0
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import sixkey.domain.entity.Log;
import sixkey.service.ILogService;

/**
 * 事件监听者
 */
@Slf4j
@Component
public class MyEventListener {

    @Autowired
    private ILogService logService;

    @Async("asyncExecutor") //开启线程池异步
    @EventListener(Log.class) //开启监听
    public void saveLog(Log sysLog){
        log.info("=========即将异步保存到数据库中=========");
        logService.save(sysLog);
    }
}
